<template>
  <div class="content-box" ref="content">
    <div class="header-card">
      <span :class="activeIndex == 1 ? 'active' : ''" @click="changeIndex(1)">指标分析</span>
      <span :class="activeIndex == 2 ? 'active' : ''" @click="changeIndex(2)">项目分析</span>

      <el-select v-model="district" class="long" @change="change1">
        <el-option v-for="item in options_district" :key="item.value" :label="item.label" :value="item.value">
        </el-option>
      </el-select>
      <div class="time" v-if="activeIndex == 1">
        {{ district_time }}
      </div>
    </div>
    <div class="main-box">
      <Target v-if="activeIndex == 1" :district="district" @sendTime="getTime" />
      <Project v-if="activeIndex == 2" :district="district" />
    </div>
  </div>
</template>
<script>
import Project from "./project.vue";
import Target from "./target.vue";
import { options_sscy, options_district } from "@/views/project_three/pages/common/optionConfig";
export default {
  data() {
    return {
      district_time: "",
      activeIndex: 1,
      district: "太原市",
      options_district: options_district,
    };
  },
  components: {
    Project,
    Target,
  },
  mounted() {
    //  this.changeSize();
    // window.onresize = () => {
    //   this.changeSize();
    // }
  },
  methods: {
    getTime(time) {
      this.district_time = time;
    },
    changeIndex(index) {
      this.activeIndex = index;
      this.district = "太原市";
    },
    change1(val) {
      this.district = val;
    },
    changeSize() {
      console.log(document.body.scrollWidth);
      if (document.body.scrollWidth > 1366) {
        let w = (document.body.scrollWidth - 330) / 1590;
        let h =
          (document.body.scrollHeight - 120) / 809 > 1
            ? 1
            : (document.body.scrollWidth - 330) / 1590 < 0.75
              ? 0.82
              : (document.body.scrollHeight - 120) / 809;
        console.log(w, h);
        this.$refs["content"].style = `
     transform: scale(${w},${h});
     -moz-transform: scale(${w},${h});
     -webkit-transform: scale(${w},${h});
     -o-transform: scale(${w},${h});
     `;
      }
    },
  },
};
</script>
<style lang="less" scoped>
.content-box {
  width: 100%;
  height: 100%;
  background: #fcf9fc;
}

.header-card {
  padding-left: 20px;
  width: 100%;
  height: 80px;
  line-height: 80px;
  background: #ffffff;
  box-shadow: 0px 2px 6px 0px rgba(4, 0, 0, 0.1);
  text-align: left;

  span {
    margin-right: 75px;
    display: inline-block;
    height: 100%;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
    cursor: default;
  }

  span.active {
    font-weight: bold;
    color: #446db3;
    border-bottom: 4px solid #446db3;
  }
}

.main-box {
  box-sizing: border-box;
  padding: 20px;
  height: calc(100% - 80px);
}

.long {
  width: 220px;
  float: right;
  margin-right: 30px;
}

.time {
  width: 220px;
  float: right;
  margin-right: 30px;
  font-size: 16px;
  font-weight: bold;
  text-align: right;
}

// .content-box {
//   width: 1590px;
//   height: 809px;
//   transform-origin: 0 0;
// }
/*
  *常用电脑尺寸  1680 * 900
  *              1536 * 864
  *              1512 * 790
  *              1440 * 900
  *ipad pro      1366 * 1024
  *ipad mini     1024 * 768
  *ipad          1024 * 768
 */
/*分辨率低于1680，采用下面的样式*/
@media screen and (max-device-width: 1680px) {}

/*分辨率低于1536，采用下面的样式*/
@media screen and (max-device-width: 1536px) {}

/*分辨率低于1440，采用下面的样式*/
@media screen and (max-device-width: 1440px) {}

/*分辨率低于1366，采用下面的样式*/
@media screen and (max-device-width: 1366px) {
  .left {
    flex: 0 0 240px;
  }
}

/*分辨率低于1180，采用下面的样式*/
@media screen and (max-device-width: 1180px) {
  .bottom-text {
    font-size: 12px;
  }

  .project>div span {
    font-size: 12px;
  }
}

/*分辨率低于1024，采用下面的样式*/
@media screen and (max-device-width: 1024px) {}
</style>
